package cn.ruituo.adv7.bank;

public class Depositer extends Thread {
    private Account ac;

    public Depositer(String n, Account ac) {
        super(n);
        this.ac = ac;
    }

    @Override
    public void run() {
         while(true){
             System.out.println(super.getName()+"存钱3000元");
             ac.deposit(3000);
             System.out.println(super.getName()+"存钱3000元后，余额是"+ac.getMoney()+"元");

             synchronized (ac){
                 ac.notifyAll();//发消息给所有等待的人
             }
             try {
                 sleep(5000);
             } catch (InterruptedException e) {
                 e.printStackTrace();
             }

         }
    }
}
